package hotel.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Component;

import hotel.entity.User;
import hotel.service.IUserService;

@Component
public class UserServiceImpl<T extends User> extends ServiceImpl<T> implements IUserService<T> {

	@Override
	public T validate(String account, String password) {
		return this.dao.findFirstResult("from User u where u.account= '"+account+"' and u.password = '"+password+"'");
	}
	
	@Override
	public boolean save(T user) {
		user.setRegisteredTime(new Date());
		return dao.save(user);
	}

	@Override
	public List<T> findUserByRole(int roleid) {
		return dao.list("from User u where u.role.roleid = "+roleid);
	}

}
